﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    /// <summary>
    /// 所有的库存查询，根据入库，可以查询入库的WB04
    /// </summary>
    public partial class TWGBST 
    {
       

        public TWGBST()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWGBST();
            MESSAGES += "WBBS10;WBBS20;WBBS21;WBBS42;WBBS43;WBBS61;WBBS62;";
            this.DataContext = MV;
            InitializeComponent();
        }

        
        
        #region====WorkFlow========
        public override void OnWorkflowIDChange(MessageEventArgs e)
        {
            try
            {
                base.OnWorkflowIDChange(e);
                MessageInfo msg = e.Info;
                string task = msg.MSGTYPE;
                switch (task)
                {
                    case "WBBS10":
                    case "WBBS20":
                    case "WBBS21":
                    case "WBBS42":
                    case "WBBS43":
                    case "WBBS61":
                    case "WBBS62":
                        ((VWGBST)MV).LOADWG(msg);
                        break;
                }
                if (vwMaster.View != null)
                {
                    vwMaster.View.MoveCurrentToFirst();
                 }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        #endregion
         
        public override void OnWDChg(DataRow _dwWD)
        {
            try
            {
                if (_dwWD == null)
                {
                    TBMain.Clear();
                    return;
                }
                MessageInfo msg = new MessageInfo();
                msg.WAKZ = _dwWD["WDWAKZ"].ToString();
                msg.ART = _dwWD["WDART"].ToString();
                msg.DESS = _dwWD["WDDESS"].ToString();
                msg.COLORIT = _dwWD["WDCOLORIT"].ToString();
                msg.FARBE = _dwWD["WDFARBE"].ToString();
                msg.BESCHICH = _dwWD["WDBESCHICH"].ToString();
                msg.VAR = _dwWD["WDVAR"].ToString();
                msg.LO = _dwWD["WDLO"].ToString();
                msg.ZUSTAND = _dwWD["WDZUSTAND"].ToString();
                msg.ZENSUR = "1";
                msg.ZENSURKZ = "A";
                ((VWGBST)MV).LOADWG(msg);
                vwMaster.View.MoveCurrentToFirst();
                base.OnWDChg(_dwWD);
            }
            catch(Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
              
            }
           
        }
        public override void QueryCommand(object sender, System.Windows.RoutedEventArgs e)
        {
            OnWDChg(dwWD);
            base.QueryCommand(sender, e);
        }
    }
}
